#define  _CRT_SECURE_NO_WARNINGS 1

#include "Sort.h"

void TestStack()
{
	Stack St;
	StackInit(&St);

	printf("StackSize: %d\n", StackSize(&St));

	StackPush(&St, 1);
	StackPush(&St, 2);
	StackPush(&St, 3);
	StackPush(&St, 4);
	StackPush(&St, 5);
	StackPush(&St, 6);

	printf("StackTop: %d\n", StackTop(&St));
	printf("StackSize: %d\n", StackSize(&St));

	while (!StackEmpty(&St))
	{
		printf("%d ", StackTop(&St));
		StackPop(&St);
	}
	printf("\n");

	printf("StackSize: %d\n", StackSize(&St));
}

void TestQuick_hoare()
{
	int n = 50;
	int* arr = (int*)malloc(n * sizeof(int));
	if (arr == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	for (int i = 0; i < n; ++i)
	{
		arr[i] = rand() % 101;
	}

	PrintArray(arr, n);
	QuickSort_hoare(arr, 0, n - 1);
	PrintArray(arr, n);

}

void TestQuick_fpsp()
{
	int n = 50;
	int* arr = (int*)malloc(n * sizeof(int));
	if (arr == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	for (int i = 0; i < n; ++i)
	{
		arr[i] = rand() % 101;
	}

	PrintArray(arr, n);
	QuickSort_fpsp(arr, 0, n - 1);
	PrintArray(arr, n);
}

void TestQuickNonR()
{
	int n = 50;
	int* arr = (int*)malloc(n * sizeof(int));
	if (arr == NULL)
	{
		perror("malloc fail");
		exit(-1);
	}

	for (int i = 0; i < n; ++i)
	{
		arr[i] = rand() % 101;
	}

	PrintArray(arr, n);
	QuickSortNonR(arr, 0, n - 1);
	PrintArray(arr, n);

}


int main()
{
	srand((unsigned int)time(NULL));
	//TestStack();
	//TestQuick_hoare();
	//TestQuick_fpsp();
	TestQuickNonR();

	return 0;
}